﻿@model MvcApplication1.Models.User
@using System.Collections.Specialized
@{
    ViewBag.Title = "AdminEditUser";
    string[] roles=Roles.GetAllRoles();
}

<h2>账户管理</h2>
@if(ViewBag.changesuccess==true)
{
    <script type="text/javascript">
        alert("保存成功");
    </script>
}
<div class="editor-label">
    @Html.LabelFor(m=>m.username,"用户名")
    @Html.DisplayFor(m => m.username)
</div>  
<div class="editor-label">
    
    @Html.LabelFor(m=>m.email,"Email")
    @Html.DisplayFor(m => m.email)
</div> 
<div class="editor-label">
    @Html.LabelFor(m=>m.lastlogin,"上次登录")
    @Html.DisplayFor(m=>m.lastlogin)
</div>  
<div class="editor-label">
    @Html.LabelFor(m=>m.creationdate,"注册时间")
    @Html.DisplayFor(m=>m.creationdate)
</div>   
@{
    using(Html.BeginForm("AdminEditUser","Admin"))
    {
        <div class="editor-label">
            @Html.LabelFor(m=>m.isapproved,"允许登录")
            @Html.CheckBoxFor(m => m.isapproved)
        </div>   
        <div class="editor-label">
            @Html.LabelFor(m=>m.role,"用户角色")
            <select id="role" name="role">
                @foreach (string role in roles)
                {
                    if (role == Model.role)
                    {
                        <option value="@role" selected="selected">@role</option>
                    }
                    else
                    {
                        <option value="@role">@role</option>
                    }
                }
            </select>
        </div>   
        <div>@Html.HiddenFor(m=>m.username)<input type="submit" value="保存" /><button type="button" onclick="window.location='@Url.Action("UserAccountManage")'">返回列表</button></div>
    }
}